﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestInst.view
{
    public partial class InputBox : UserControl
    {

        public InputBox()
        {
            InitializeComponent();
        }

        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            if (NameTB.Text == "")
            {
                MessageBox.Show("You must enter a name.", "Name Entry Error",
                   MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                // Code to act on the data entered would go here.
                MessageBox.Show("You get it.", "OK",
                   MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        private void NameTB_TextChanged(object sender, System.EventArgs e)
        {
            if (InputBoxValueChanged != null)
                InputBoxValueChanged(this, new TextChangeEventArgs(this.NameTB.Text));

        }


        /// <summary>
        /// define an event
        /// </summary>
        public event TextBoxChangedHandle InputBoxValueChanged;
        public delegate void TextBoxChangedHandle(object sender, TextChangeEventArgs e);


        public class TextChangeEventArgs : EventArgs
        {
            private string message;
            public TextChangeEventArgs(string message)
            {
                this.message = message;
            }
            public string Message
            {
                get { return message; }
            }
        }
    }
}
